package com.netposa.datawarehouse.statistics.controller;

import com.netposa.appwebres.WebResCallback;
import com.netposa.appwebres.common.WebResCriteria;
import com.netposa.appwebres.common.WebResInfo;
import com.netposa.appwebres.exception.WebResException;
import com.netposa.datawarehouse.statistics.service.PccService;
import com.netposa.vdt.pccclient.exception.PccHandleException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping({"/pcc_statistics"})
public class PccStatisticsController {
   @Autowired
   PccService pccService;

   @GetMapping({"/compute_state"})
   public WebResInfo computeState() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            try {
               criteria.addSingleResult(PccStatisticsController.this.pccService.computeState());
            } catch (PccHandleException var4) {
               throw new WebResException("500");
            }
         }
      }).sendRequest(new Object[0]);
   }

   @GetMapping({"/task_count"})
   public WebResInfo taskCount() {
      return (new WebResCallback() {
         public void execute(WebResCriteria criteria, Object... params) {
            criteria.addSingleResult(PccStatisticsController.this.pccService.taskCount());
         }
      }).sendRequest(new Object[0]);
   }
}
